package org.apache.jsp.procesa;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import beans.BeanImagenes;
import mapping.ImagenLugar;

public final class proc_005fgaleria_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=utf-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"../error/errorpage.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');
      out.write('\n');
      beans.BeanImagenes mybean = null;
      synchronized (_jspx_page_context) {
        mybean = (beans.BeanImagenes) _jspx_page_context.getAttribute("mybean", PageContext.PAGE_SCOPE);
        if (mybean == null){
          mybean = new beans.BeanImagenes();
          _jspx_page_context.setAttribute("mybean", mybean, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\n");
      out.write("\t\n");
      out.write("\t");
	
	mybean.conectar();
	int id_elem_mapa = Integer.parseInt(request.getParameter("elem_mapa")); 
	
	System.out.println("Ejecutando galeria...");
	List listaImg = mybean.getImagenes(id_elem_mapa);
	Iterator it = listaImg.iterator();
	int numimg = 0;
	StringBuffer sb = new StringBuffer("");
	while(it.hasNext()){
		String path = ((ImagenLugar)it.next()).getRuta_imagen_lugar();	
		path = path.substring(path.lastIndexOf("/") + 1);
		sb.append(path + " ");
		numimg++;
	}
	System.out.println("Numero de imagenes para lugar con id: " + id_elem_mapa + " -> " + numimg);
	System.out.println(sb.toString());
	
      out.write("\n");
      out.write("\t<div style=\"float: right\"><img src=\"images/web/cerrar.gif\" onclick=\"cerrarGaleria()\"/></div>\n");
      out.write("\t");

	if(numimg>0){
	
      out.write(" \n");
      out.write("\t\t<br/>\n");
      out.write("\t\t<center>\n");
      out.write("\t\t\t<button id=\"btnstop\">Detener</button>\n");
      out.write("\t\t\t<button id=\"btnplay\" disabled=\"disabled\">Continuar</button>\n");
      out.write("\t\t\t<button id=\"btnanteriorimg\" disabled=\"disabled\"><img src = \"images/web/izq2.gif\" alt = \"&lt;\" style = \"opacity:0.4\"/></button>\n");
      out.write("\t\t\t<button id=\"btnsiguienteimg\" disabled=\"disabled\"><img src = \"images/web/dcha2.gif\" alt = \"&gt;\" style = \"opacity:0.4\"/></button>\n");
      out.write("\t\t</center>\n");
      out.write("\t\t<br>\n");
      out.write("\t\t<div id=\"contentslider\">\n");
      out.write("\t\t\t<div id=\"barra\">\n");
      out.write("\t\t\t\t<div id=\"deslizador\" title=\"Deslize este controlador hacia uno de los lados\"></div>\n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t\n");
      out.write("\t\t<div class=\"centrado\">\n");
      out.write("\t\t\t<br/>\n");
      out.write("\t\t\t<span id=\"velocidad\">-  Velocidad:<span id=\"infovelocidad\"></span>  +</span>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t<div id=\"infovisor\"><p>Viendo imagen <span id=\"contadorimg\"></span> de <span id=\"totalimg\"></span></p>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t\n");
      out.write("\t\t<div id=\"contenidoimg\">\n");
      out.write("\t\t\t<div id=\"capaimg\"></div>\n");
      out.write("\t\t</div>\n");
      out.write("\t\t\n");
      out.write("\t\t<script>\n");
      out.write("\t\t\tcomenzar('");
      out.print(sb.toString());
      out.write("', false);\n");
      out.write("\t\t</script>\n");
      out.write("\n");
      out.write("\t<br/>\n");
      out.write("\t");
}
	else{ 
      out.write("\n");
      out.write("\t\t<div style = \"text-align:center; font-size: 16px\">\n");
      out.write("\t\t\t<div class=\"error\">\n");
      out.write("\t\t\tA&uacute;n no tenemos im&aacute;genes disponibles para este lugar.\n");
      out.write("\t\t\t</div>\n");
      out.write("\t\t</div>\n");
      out.write("\t");
} 
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
